package com.rc.saas.tenant.base;

import com.rc.saas.tenant.common.constant.ShiroConstants;
import com.rc.saas.tenant.model.tenant.TenantUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;

import java.io.Serializable;
import java.util.List;

/**
 * Created by sven on 2019/1/17
 */
public class BaseSearch extends BaseModel implements Serializable {

    private String dataAuth;//数据权限 100 平台权限, 010 加盟商权限,001企业权限,111全部权限 默认111 不能为000(需根据代码先获取)
    private String roleType;//角色类型 ( 0 超级管理员 1 普通用户 2加盟商 3企业用户) 默认1`(需根据代码先获取)
    private Long baseOperatorId;//加盟商ID
    private Long baseEnterpriseId;//企业id

    private String tenantCode;

    private String loginName;

    private String tenantOperatorCode;

    private List<String> operatorIds;

    private List<String> enterpriseIds;

    private Integer offset=1;
    private Integer limit=10;

    public BaseSearch() {
        Session session = SecurityUtils.getSubject().getSession();
        TenantUser user = (TenantUser) session.getAttribute(ShiroConstants.SESSION_TENANT_USER_KEY);
        if (user != null) {
            this.tenantCode = user.getTenantCode();
            this.tenantOperatorCode = user.getTenantOperatorCode();
        }
    }

    public List<String> getOperatorIds() {
        return operatorIds;
    }

    public void setOperatorIds(List<String> operatorIds) {
        this.operatorIds = operatorIds;
    }

    public List<String> getEnterpriseIds() {
        return enterpriseIds;
    }

    public void setEnterpriseIds(List<String> enterpriseIds) {
        this.enterpriseIds = enterpriseIds;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getTenantCode() {
        return tenantCode;
    }

    public void setTenantCode(String tenantCode) {
        this.tenantCode = tenantCode;
    }

    public String getTenantOperatorCode() {
        return tenantOperatorCode;
    }

    public void setTenantOperatorCode(String tenantOperatorCode) {
        this.tenantOperatorCode = tenantOperatorCode;
    }

    public Integer getOffset() {
        return offset;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    public String getDataAuth() {
        return dataAuth;
    }

    public void setDataAuth(String dataAuth) {
        this.dataAuth = dataAuth;
    }

    public String getRoleType() {
        return roleType;
    }

    public void setRoleType(String roleType) {
        this.roleType = roleType;
    }

    public Long getBaseOperatorId() {
        return baseOperatorId;
    }

    public void setBaseOperatorId(Long baseOperatorId) {
        this.baseOperatorId = baseOperatorId;
    }

    public Long getBaseEnterpriseId() {
        return baseEnterpriseId;
    }

    public void setBaseEnterpriseId(Long baseEnterpriseId) {
        this.baseEnterpriseId = baseEnterpriseId;
    }
}
